Skip to content

feat(cni): replace GoBGP direct calls with BGPVRFInstance CRD#113

Merged
privateip merged 1 commit into
mainfrom
feat/cni-bgpvrfinstance-refactor
Jun 16, 2026
Merged

feat(cni): replace GoBGP direct calls with BGPVRFInstance CRD#113
privateip merged 1 commit into
mainfrom
feat/cni-bgpvrfinstance-refactor

Conversation

@privateip

Copy link
Copy Markdown
Contributor

Summary

  • Replaces direct GoBGP gRPC calls in the CNI with BGPVRFInstance CRD create/delete; cosmos reconciles BGP state asynchronously, decoupling the CNI from the GoBGP implementation
  • Fixes a BGP route distinguisher collision: switches from routerID:vrfTableID (Type 1, shared per-cluster routerID + locally-allocated volatile table ID) to ASN:uint32(vpcHex) (Type 0, stable and globally unique per VPC); also eliminates the 65535 Type 1 NN wire limit
  • Fixes BGP teardown ordering in cmdDel: BGPVRFInstance is deleted immediately after RouteIngressDel so remote peers receive the withdrawal before local forwarding state is removed
  • Switches containerlab worker BGPInstance manifests (iad/sjc/dfw) from routerIDSource: Manual to Auto so each node derives a unique router ID from its IPv6 InternalIP (route reflector left unchanged)
  • Removes resolveRouterID and all node-lookup logic from the CNI; router ID is no longer needed for RD computation
  • Adds unit tests for all CNI helper functions (parseConf, bgpVRFInstanceName, routeDistinguisher, routeTarget, lookupBGPConfig) using controller-runtime fake client; no kernel privileges required

Breaking change

Existing BGPVRFInstance objects must be deleted before deploying. The RD changes for every instance (both the formula and the NN component). BGP will withdraw the old RD and advertise the new one after cosmos reconciles; traffic to affected VPCs is interrupted until re-advertisement completes.

Test plan

  • task lint — 0 issues
  • task test:unit — all tests pass with -race
  • Deploy updated BGPInstance manifests to a containerlab environment and confirm per-node router IDs are derived from IPv6 InternalIP
  • Attach a pod and verify BGPVRFInstance is created with ASN:uint32(vpcHex) RD format
  • Delete the pod and verify BGPVRFInstance is deleted before veth/VRF teardown

🤖 Generated with Claude Code

Refactor the CNI plugin to manage BGP VRF configuration through
Kubernetes CRDs (BGPVRFInstance) instead of calling GoBGP APIs
directly, and fix a route distinguisher collision that caused
ambiguous BGP advertisements across cluster nodes.

- Replace direct GoBGP gRPC calls with BGPVRFInstance create/delete
  on container ADD/DEL; cosmos reconciles BGP state asynchronously
- Switch RD formula from routerID:vrfTableID (Type 1, volatile) to
  ASN:uint32(vpcHex) (Type 0, stable and globally unique per VPC);
  eliminates both the per-node collision and the 65535 Type 1 NN
  wire limit
- Remove resolveRouterID and all node-lookup logic from the CNI;
  routerID is no longer needed for RD computation
- Switch containerlab worker BGPInstance manifests (iad/sjc/dfw)
  from routerIDSource Manual to Auto so each node derives a unique
  router ID from its IPv6 InternalIP (route reflector unchanged)
- Order BGPVRFInstance deletion before local data-plane teardown in
  cmdDel so BGP withdrawal reaches remote peers before forwarding
  state is removed
- Add unit tests for all CNI helper functions using controller-runtime
  fake client; no kernel privileges required

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@privateip privateip requested a review from a team as a code owner June 16, 2026 16:12
@privateip privateip merged commit c1f46ea into main Jun 16, 2026
5 checks passed
@privateip privateip deleted the feat/cni-bgpvrfinstance-refactor branch June 16, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants